package com.yy.job.boot.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yy.job.boot.constants.JobBootConstants;
import com.yy.job.facade.JobFacade;
import com.yy.job.facade.model.YYJobModel;
import com.yy.job.facade.model.YYJobStepModel;

@Service
public class CaseDemo3Service {
	
	@Autowired
	private JobFacade jobFacade;
	
	public Long create() throws Exception {
		// moduleCode和jobCode必须和xml中配置的保持一致
		YYJobModel jobModel = new YYJobModel();
		jobModel.setProjectCode(JobBootConstants.PROJECT_CODE);
		jobModel.setModuleCode("module1");
		jobModel.setJobCode("jobCode1");
		jobModel.setBusinessNo("bus_" + new Date().getTime());
		jobModel.setOperator("operator1");
		
		// 步骤1,stepCode必须和xml中配置的保持一致
		YYJobStepModel task1 = new YYJobStepModel();
		task1.setStepCode("jobTask1");
		// 设置提交参数。步骤在执行的时候，可以获取此参数
		task1.setStepParams("id=1&name=yy-job");
		jobModel.addJobStep(task1);
		
		// 提交
		Long submitJob = this.jobFacade.submitJob(jobModel);
		
		return submitJob;
	}
}
